<template>
	<view>
		<view class="m-bg-c">
			<view class="m-card">
				<u--form labelPosition="left" :model="form" ref="uForm" :rules="rules" errorType="toast">
					<u-form-item label="电视机" prop="name" ref="item1" labelWidth="120rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.name" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="电话柜" prop="sex" ref="item1" labelWidth="120rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.sex" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="机顶盒+IC卡" prop="setop" ref="item1" labelWidth="200rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.setop" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="音响" prop="sound" ref="item1">

						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.sound" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="DVD" prop="audio" ref="item1">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.audio" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="沙发" prop="sofa" ref="item1">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.sofa" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="茶几" prop="table" ref="item1">

						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.table" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="餐台" prop="dining" ref="item1">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.dining" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="餐椅" prop="chair" ref="item1">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.chair" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="窗帘" prop="curtains" ref="item1">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.curtains" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="空调" prop="air" ref="item1">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.air" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="冰箱" prop="refri" ref="item1">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.refri" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="洗衣机" prop="machine" ref="item1" labelWidth="120rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.machine" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="燃气炉" prop="furnace" ref="item1" labelWidth="120rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.furnace" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="抽油烟机" prop="smoke" ref="item1" labelWidth="150rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.smoke" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="消毒柜" prop="lizer" ref="item1" labelWidth="120rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.lizer" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="微波炉" prop="oven" ref="item1" labelWidth="120rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.oven" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="热水器" prop="heater" ref="item1" labelWidth="120rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.heater" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="床" prop="bed" ref="item1">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.bed" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="床垫" prop="mattress" ref="item1">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.mattress" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="床头柜" prop="cupboard" ref="item1" labelWidth="120rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.cupboard" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="衣柜" prop="wardrobe" ref="item1">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.wardrobe" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="电脑桌" prop="computer" ref="item1" labelWidth="120rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.computer" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="椅子" prop="chaira" ref="item1">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.chaira" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="梳妆台" prop="dresser" ref="item1" labelWidth="120rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.dresser" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="饮水机" prop="water" ref="item1" labelWidth="120rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.water" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="保险柜" prop="safe" ref="item1" labelWidth="120rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.safe" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="房卡" prop="room" ref="item1">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.room" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="门禁卡" prop="guard" ref="item1" labelWidth="120rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.guard" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="钥匙" prop="keys" ref="item1">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.keys" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="燃气卡" prop="fcard" ref="item1" labelWidth="120rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.fcard" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<!-- <u-form-item label="燃气炉" prop="rnace" ref="item1" labelWidth="120rpx">
						<u-search shape="square" searchIcon=' ' :clearabled='false' height='64' :showAction='false'
							v-model="form.rnace" bgColor='#eee' placeholder='请输入'>
						</u-search>
					</u-form-item> -->
					<u-form-item label="电费存折" prop="passbook" ref="item1" labelWidth="150rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.passbook" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="电气卡" prop="electrical" ref="item1" labelWidth="120rpx">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.electrical" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="水表" prop="meter" ref="item1">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.meter" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
					<u-form-item label="电表" prop="hour" ref="item1">
						<view class="boxhuxing u-flex u-flex-items-center">
							<u--input type='number' v-model="form.hour" placeholder='请输入' border="none">
							</u--input>
						</view>
					</u-form-item>
				</u--form>

				<view class="queren" @click="submit">确认无误，进行提交</view>
			</view>
		</view>
	</view>
</template>

<script>
	const d = new Date()
	const mytime = d.toLocaleString(); // 获取日期与时间
	export default {
		data() {
			return {
				form: {
					name: '',
					sex: '',
					setop: '',
					sound: '',
					audio: '',
					sofa: '',
					table: '',
					dining: '',
					chair: '',
					curtains: '',
					air: '',
					refri: '',
					machine: '',
					furnace: '',
					smoke: '',
					lizer: '',
					oven: '',
					heater: '',
					bed: '',
					mattress: '',
					cupboard: '',
					wardrobe: '',
					computer: '',
					chaira: '',
					dresser: '',
					water: '',
					safe: '',
					room: '',
					guard: '',
					keys: '',
					fcard: '',
					rnace: '',
					passbook: '',
					electrical: '',
					meter: '',
					hour: ''
				},
				rules: {
					name: [{
							required: true,
							message: '电视机不能为空',
							trigger: ['blur', 'change']
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					sex: [{
							required: true,
							message: '电视柜不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					setop: [{
							required: true,
							message: '机顶盒+IC卡不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					sound: [{
							required: true,
							message: '音响不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					audio: [{
							required: true,
							message: 'DVD不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					sofa: [{
							required: true,
							message: '沙发不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					table: [{
							required: true,
							message: '茶几不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					dining: [{
							required: true,
							message: '餐台不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					chair: [{
							required: true,
							message: '餐椅不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					curtains: [{
							required: true,
							message: '窗帘不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					air: [{
							required: true,
							message: '空调不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					refri: [{
							required: true,
							message: '冰箱不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					machine: [{
							required: true,
							message: '洗衣机不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					furnace: [{
							required: true,
							message: '燃气炉不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					smoke: [{
							required: true,
							message: '抽油烟机不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					lizer: [{
							required: true,
							message: '消毒柜不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					oven: [{
							required: true,
							message: '微波炉不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					heater: [{
							required: true,
							message: '热水器不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					bed: [{
							required: true,
							message: '床不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					mattress: [{
							required: true,
							message: '床垫不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					cupboard: [{
							required: true,
							message: '床头柜不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					wardrobe: [{
							required: true,
							message: '衣柜不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					computer: [{
							required: true,
							message: '电脑桌不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					chaira: [{
							required: true,
							message: '椅子不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					dresser: [{
							required: true,
							message: '梳妆台不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					water: [{
							required: true,
							message: '饮水机不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					safe: [{
							required: true,
							message: '保险柜不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					room: [{
							required: true,
							message: '房卡不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					guard: [{
							required: true,
							message: '门禁卡不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					keys: [{
							required: true,
							message: '钥匙不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					fcard: [{
							required: true,
							message: '燃气卡不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					rnace: [{
							required: true,
							message: '燃气炉不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					passbook: [{
							required: true,
							message: '电费存折不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					electrical: [{
							required: true,
							message: '电气卡不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					meter: [{
							required: true,
							message: '水表不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					],
					hour: [{
							required: true,
							message: '电表不能为空',
							trigger: 'blur'
						},
						{
							pattern: /^[+]{0,1}(\d+)$/g,
							message: '请输入整数字'
						}
					]
				},
				ids: ''
			}
		},
		onReady() {
			this.$refs.uForm.setRules(this.rules);
		},
		onLoad(e) {
			if (e.id) {
				this.ids = e.id
				console.log(this.ids, '拿到清单id')
			}
		},
		methods: {
			submit() {
				this.$refs.uForm.validate().then(res => {
					let arr1 = []
					for (let var1 in this.form) {
						if (this.form[var1]) {
							arr1.push({
								name: var1,
								value: this.form[var1]
							})
						}
					}
					this.tijiao(JSON.stringify(arr1));
				}).catch(errors => {
					// uni.$u.toast('校验失败')
				})
			},
			async tijiao(e) {
				if (e) {
					let res = await this.require('getFurniture', { //提交家私清单并确认已租房下架房子
						id: this.ids,
						furniture: e
					})
					if (res) {
						console.log(res,'成功')
						this.nextNav('/pages/zufang/yanzheng?time=' + mytime)
					}
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.m-bg-c {
		background: linear-gradient(#0e5642, #0E5642 180rpx, #f6f5f5 180rpx, #F2F2F2 100%);
		min-height: 100vh;
		padding: 30rpx;
	}

	.boxhuxing {
		height: 64rpx;
		background-color: #eee;
		border-radius: 8rpx;
	}

	.queren {
		width: 350rpx;
		height: 70rpx;
		margin: auto;
		margin-top: 60rpx;
		background-color: #0E5543;
		border-radius: 15rpx;
		color: #fff;

		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>
